<?php
/**
 * Notes:
 * User: LiaoHong
 * Date: 2025/10/20
 * Time: 9:02
 **/


namespace App\Http\Controllers\User;

use App\Http\Controllers\Controller;
use App\Http\Requests\User\PermissionRequest;
use App\Services\User\PermissionService;

class PermissionController extends Controller
{
    /** @var PermissionService */
    private PermissionService $permissionService;

    public function __construct(PermissionService $service)
    {
        $this->permissionService = $service;
    }
    /**
     * @Notes:添加部门
     * @author: Liao Hong
     * @Time: 2025/10/20   9:30
     * @Interface add
     */
    public function add(PermissionRequest $request)
    {
        $data = $request->input();
        return success($this->permissionService->add($data));
    }

    /**
     * @Notes:获取部门结构树
     * @author: Liao Hong
     * @Time: 2025/10/22   9:07
     * @Interface deptTree
     */
    public function deptTree(){
        return success($this->permissionService->deptTree());
    }

    /**
     * @Notes:获取部门单条信息
     * @param PermissionRequest $request
     * @return \Illuminate\Http\JsonResponse
     * @author: Liao Hong
     * @Time: 2025/10/21   14:19
     * @Interface getRow
     */
    public function getRow(PermissionRequest $request)
    {
        $data = $request->input();
        return success($this->permissionService->getRow($data));
    }
    /**
     * @Notes:修改部门
     * @author: Liao Hong
     * @Time: 2025/10/20   9:30
     * @Interface add
     */
    public function update(PermissionRequest $request)
    {
        $data = $request->input();
        return success($this->permissionService->update($data));
    }
    /**
     * @Notes:删除部门
     * @author: Liao Hong
     * @Time: 2025/10/20   9:30
     * @Interface add
     */
    public function delete(PermissionRequest $request)
    {
        $data = $request->input();
        return success($this->permissionService->delete($data));
    }
    /**
     * @Notes:部门列表
     * @author: Liao Hong
     * @Time: 2025/10/20   9:30
     * @Interface add
     */
    public function list(PermissionRequest $request)
    {

        $data = $request->input();
        return success($this->permissionService->list($data));
    }

}
